void main() {
  Teacher t = Teacher(name: "老高");
  Student s = Student(name: "张三");
  t.eat();
  s.work();
}

class Person {
  String? name;
  int? age;
  String? sex;
  double? height;
  double? weight;
  String? hobby;

  //  同名
  Person({this.name, this.age, this.sex, this.hobby, this.height, this.weight});

  eat() {
    print('$name在吃饭');
  }

  sleep() {
    print('$name在睡觉');
  }

  run() {
    print('$name在跑步');
  }

  work() {
    print('$name在工作');
  }
}

// Teacher
class Teacher extends Person with PersonUtils, HomeUtils {
  // 继承父类构造函数
  // super 当前的父类构造函数对象
  Teacher(
      {String? name,
      int? age,
      String? sex,
      double? height,
      String? hobby,
      double? weight})
      : super(
            name: name, age: age, height: height, hobby: hobby, weight: weight);

  // 两部 第一步 接收teacher传递过来的参数
  // 调用父类的构造函数 把值传递过去
  @override
  eat() {
    // TODO: implement eat
    // return super.eat();
    print("老子叫$name, 老在喝早茶");
    this.getVaction(this.name!);
    this.doHouseWork(this.name!);
  }
}

// Student with混入mixin类 就可以直接调用方法
class Student extends Person with PersonUtils, HomeUtils {
  Student(
      {String? name,
      int? age,
      String? sex,
      double? height,
      String? hobby,
      double? weight})
      : super(
            name: name, age: age, height: height, hobby: hobby, weight: weight);
  @override
  work() {
    // TODO: implement work
    super.work(); // 执行父类的方法
    print("$name工作完摸鱼"); // 执行自己的方法
    this.getVaction(this.name!);
    this.doHouseWork(this.name!);
  }
}

// 此时都需要一个放假的方法，又不想直接影响基类

mixin PersonUtils {
  // 混入工具
  getVaction(String name) {
    print('$name在放假');
  }
}

mixin HomeUtils {
  // 混入工具
  doHouseWork(String name) {
    print('$name在做家务');
  }
}
